home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / bin / search-path < prev    next >
Text File  |  2007-02-15  |  450b  |  25 lines

  1. #!/bin/sh -e
  2. # A cut-down version of 'which' from debianutils. Returns zero if executable
  3. # $1 is found on $PATH.
  4. PROGRAM="$1"
  5. IFS=:
  6. RET=1
  7. case $PROGRAM in
  8.     */*)
  9.         if [ -f "$ELEMENT/$PROGRAM" ] && \
  10.            [ -x "$ELEMENT/$PROGRAM" ]; then
  11.             exit 0
  12.         fi
  13.         ;;
  14.     *)
  15.         for ELEMENT in $PATH; do
  16.             if [ -z "$ELEMENT" ]; then ELEMENT=.; fi
  17.             if [ -f "$ELEMENT/$PROGRAM" ] && \
  18.                [ -x "$ELEMENT/$PROGRAM" ]; then
  19.                 exit 0
  20.             fi
  21.         done
  22.         ;;
  23. esac
  24. exit 1
  25.